At tollgates on a freeway, etc., vehicle identification number recognition devices are provided to capture an image of a license plate of a vehicle and recognize a vehicle identification number. Upon installation of the vehicle identification number recognition device, it is necessary to focus a camera of the vehicle identification number recognition device on a license plate. In the case of manual focusing, a focusing accuracy varies depending on an adjustment ability of an operator and thus, a recognition rate of the vehicle identification number recognition device may possibly not be constant. Conceivable examples of an approach to stabilize the recognition rate include a method of searching for a value that provides the finest image, i.e., a focusing position, by setting an imaging distance, i.e., a distance between an optical system and an element, or a focusing distance of the optical system for all possible values and then capturing the image. However, this method has a problem that it takes time to search for a focusing position.
As the method of detecting a focusing position, hill climbing (hill climbing algorithm) has been known (see, for example, Patent Document 1). The hill climbing is to capture an image while gradually changing an imaging distance in an optical axis direction so as to search for an imaging distance at which an evaluation score indicating an edge intensity of the captured image (i.e., sharpness) peaks. By adopting the hill-climbing, it is possible to search for a focusing position as well as reduce an amount of movement of the optical system or the element (this is because if a peak position is found, further focal adjustment is unnecessary). Specifically, the time necessary for searching for a focusing position can be reduced.